#include<bits/stdc++.h>
using namespace std;

struct number
{
	string x;
	bool operator < (const number & a) const
	{
		return a.x+x<x+a.x;
	}
};

int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		number num[n+1];
		for(int i=1;i<=n;i++)
			cin>>num[i].x;
		sort(num+1,num+n+1);
		for(int i=1;i<=n;i++)
			cout<<num[i].x;
		cout<<endl;
	}
    return 0;
}
